﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using System.ServiceModel.Description;
using ClassLibrary1;

namespace HelloWCFService
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8090/MyService");

            ServiceHost host = new ServiceHost(typeof(HelloWCFService), baseAddress);

            host.AddServiceEndpoint(typeof(IHelloWCF), new WSHttpBinding(), "HelloWCFService");

            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            host.Description.Behaviors.Add(smb);

            host.Open();

            Console.WriteLine("Service is Ready");
            Console.WriteLine("Press Any Key to Terminated...");
            Console.ReadLine();

            host.Close();  
        }
    }


    public class HelloWCFService : IHelloWCF
    {
        public string HelloWCF()
        {
            return "Hello WCF!";
        }
    }  
}
